package com.csust.travel.controller;


import com.csust.travel.entity.ProductOrder;
import com.csust.travel.model.R;
import com.csust.travel.service.ProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/product/order")
@CrossOrigin
public class ProductOrderController {

    @Autowired
    private ProductOrderService productOrderService;


    @GetMapping("/stat")
    public R<Map> getUserOrderStat(){
        HashMap<String,String> map = productOrderService.getUserOrderStat();
        return R.ok(map);
    }


    @GetMapping("/my/sell")
    public  R<List<ProductOrder>> getMySellOrder(){
        List<ProductOrder> list = productOrderService.getMySellOrder();
        return R.ok(list);
    }

    @GetMapping("/my/buy")
    public R<List<ProductOrder>> getMyBuyOrder(){
        List<ProductOrder> list = productOrderService.getMyBuyOrder();
        return R.ok(list);
    }
}
